package com.ts.util;


import com.ts.proj.entity.SystemMenuEntity;
import com.ts.proj.service.SystemMenuService;

import java.util.ArrayList;
import java.util.List;

public class TreeMenuUtil {

    public List<PageData> getTreeMenu(List<SystemMenuEntity> menu, SystemMenuService systemMenuService){
        List<PageData> menuResult = new ArrayList<PageData>();
        for(SystemMenuEntity parentPageData : menu){
            PageData temp = new PageData();
            temp.put("PARENT_ID",String.valueOf(parentPageData.getId()));
            PageData pageData = new PageData();
            pageData.put("parentId", String.valueOf(parentPageData.getId()));
            List<SystemMenuEntity> firstSubMenu = systemMenuService.findAll(pageData);
            temp.put("MENU_ID",parentPageData.getId());
            temp.put("MENU_NAME",parentPageData.getMenuName());
            temp.put("MENU_URL",parentPageData.getMenuURL());
            temp.put("PARENT_ID",parentPageData.getParentId());
            temp.put("MENU_ORDER",parentPageData.getMenuOrder());
            temp.put("MENU_ICON",parentPageData.getMenuIcon());
            temp.put("MENU_TYPE",parentPageData.getMenuType());
            temp.put("MENU_STATE","0");
            temp.put("firstSubMenu",firstSubMenu);
            menuResult.add(temp);
        }
        return menuResult;
    }
}
